package 关于重写Object类的equals方法相关问题;

import java.util.Objects;

public class Test {
    public static void main(String[] args) {
        Student_1 stu1=new Student_1(1,"xc",21,"100");
        Student_1 stu1_2=new Student_1(1,"xc",21,"100");
        Student_2 stu2=new Student_2(1,"xc",21,"100");

        System.out.println(stu1.equals(stu1_2));

        int id = stu1.getId();
        Integer it=id;
        System.out.println(it.equals(stu2.id));
        System.out.println(it.equals("1"));

        System.out.println(Objects.equals(stu1.getId(), stu2.id));

        System.out.println("--------------------");
        //比较同一个类的不同对象，调用返回他们的字节码文件，是否相同?
        Class<? extends Student_1> aClass1 = stu1.getClass();
        Class<? extends Student_1> aClass1_2 = stu1_2.getClass();
        Class<? extends Student_2> aClass2 = stu2.getClass();
        Student_3 stu3=new Student_3();
        Class<? extends Student_3> aClass3 = stu3.getClass();
        System.out.println(aClass1.equals(aClass1_2));
        System.out.println(aClass1.equals(aClass2));
        System.out.println(aClass1.equals(aClass3));

        System.out.println("--------------------------------------------");
        Student_1 student1=new Student_1(1,"xc",21,"100");
        Student_1 student2=new Student_1(22,"lmf",22,"1000");
        System.out.println(student1.getClass().equals(student2.getClass()));
    }

}
